package exe3.carrent;


import java.util.Scanner;

public class Manager {
    private int pos=0;//记录车辆数量
    private Car[] cars=new Car[10];
    private  Rentalcompany [] r=new Rentalcompany[20];
    Scanner in=new Scanner(System.in);
    public int getPos() {
        return pos;
    }

    public void setPos(int pos) {
        this.pos = pos;
    }

    public Manager(){
        cars[0]=new LittleCar("京NY28588","宝马X6",800,"轿车",true,4);
        cars[1]=new LittleCar("京CNY3284","宝马550i",600,"轿车",false,4);
        cars[2]=new LittleCar("京NT37465","别克林荫大道",300,"轿车",false,4);
        cars[3]=new LittleCar("京NT96968","别克GL8",600,"轿车",true,4);
        cars[4]=new PassengerCar("京6566754","金杯",800,16,true,"大客");
        cars[5]=new PassengerCar("京8696997","金龙",800,16,true,"大客");
        cars[6]=new PassengerCar("京9696996","金杯",1500,34,false,"大客");
        cars[7]=new PassengerCar("666","金龙",1500,34,true,"大客");
        pos=8;
        }


        //显示全部信息
        public  void showCarList(){
        for (int i=0;i<cars.length;i++){
            if (cars[i]==null)
                break;
            System.out.println(cars[i].toString());
        }
    }





 //显示租聘信息
    public  void addTrs(Rentalcompany rentalcompany){
        for (int i=0;i<r.length;i++){
            if (r[i]==null){
                r[i]=rentalcompany;
                return;
            }
        }
    }



    //租车
    public void rentcar () {
        System.out.println("请输入要租赁的车型(大客\t轿车)");
        String carType=in.next();
        for (int i = 0; i < getPos(); i++) {
            if (!cars[i].isLease()) {
                continue;
            }
            if (cars[i].getModel().equals(carType))
                System.out.println(cars[i]);
        }
        System.out.println("请输入要租借的车牌号：");
        String carNum=in.next();
        System.out.println("请输入租借天数:");
        int days=in.nextInt();
        for (int i=0;i<getPos();i++){
            if (!cars[i].isLease()){
                continue;
            }
            if (cars[i].getCarNum().equals(carNum)){
                System.out.println("租借成功");
                System.out.println("您租借的是"+cars[i].getCarNum()+"\t"+cars[i].getBrand()+"\t"+cars[i].getModel()+"\t"+cars[i].getSeatNum());
                System.out.println("价格为"+cars[i].countRent(days));
                cars[i].setLease(false);
                return;
            }
        }
    }



    //还车
     public  void returnthecar(String brand){
        for (int i=0;i<pos;i++){
            if (cars[i].getCarNum().equals(brand)){
                cars[i].setLease(true);
                System.out.println("还车成功");
                return;
            }
        }
         System.out.println("失败了");
     }



    //报废
     public  void scrap(String name){
       for (int i=0;i<pos;i++){
           if (cars[i].getCarNum().equals(name)){
               for (int j=i;i<cars.length-1;j++){
                   if (cars[i]!=null){
                       cars[j]=cars[j+1];
                   }
                   System.out.println("报废成功");
                   pos--;
                   return;
               }
           }
       }
         System.out.println("报废失败");
    }


     //新增车辆
     public  void  AddCar(){
         System.out.println("请输入要租的车牌号");
         int i=in.nextInt();
         System.out.println("请输入租金:");
         int a=in.nextInt();
         System.out.println("请输入座位号:");
         int s=in.nextInt();


     }

    //车辆记录
     public void record(){

     }
}



